﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditor.AnimatedValues;
/// <summary>
/// fade渐进显示组，以及组参数缩进
/// </summary>

public class GameSetting_Fade : EditorWindow {

    AnimBool m_ShowExtraFields;
    string m_String;
    Color m_Color = Color.white;
    bool m_bol = false;

    [MenuItem("Window/My Game/EditorWindow_Fade")]
    public static void ShowGameSettingWindow()
    {
        EditorWindow.GetWindow(typeof(GameSetting_Fade));
    }

    void OnEnable()
    {
        m_ShowExtraFields = new AnimBool(false);
        m_ShowExtraFields.valueChanged.AddListener(Repaint);
        m_String = "123";
    }

    private void OnGUI()
    {
        m_ShowExtraFields.target = EditorGUILayout.ToggleLeft("Show extra fields", m_ShowExtraFields.target);//target 布尔值，表示补间动画方向，同时表示了toogle框

        //if (EditorGUILayout.BeginFadeGroup(m_ShowExtraFields.faded))//输入0-1.渐进显示，0为全部hide，同时返回false关闭整个组
        {
            EditorGUI.indentLevel++;//该显示区域的缩进等级
            EditorGUI.indentLevel++;
            EditorGUILayout.PrefixLabel("Color");
            m_Color = EditorGUILayout.ColorField(m_Color);
            EditorGUILayout.PrefixLabel("Text");
            m_String = EditorGUILayout.TextField(m_String);
           EditorGUILayout.PrefixLabel("Bool");//可以不输入下面toggle的label，直接通过此方法在其上方显示
            m_bol = EditorGUILayout.Toggle("Bool",m_bol);
            EditorGUI.indentLevel--;
            EditorGUI.indentLevel--;//缩进等级回复，不要影响到组后其他UI也缩进了
        }
        EditorGUILayout.EndFadeGroup();

    }


}
